<?php

/************************************

EasyCB, Community Forum Software
Copyright (C) 2007  Jonathon D. Keogh <jonathon.keogh@gmail.com>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

$Id: page.admin.config.php 107 2007-09-05 14:29:48Z jonathon.keogh $

************************************/

require "inc.func.php";

if(!user_loggedin() || user_level(user_name(sess_get("UserID"))) < 2)
{
	page_redirect("page.boards.php");
}

page_header("Configuration");

$_boardname = config_get("BoardName");
$_boardintroduction = config_get("BoardIntroduction");
$_boardrules = config_get("BoardRules");

if(isset($_POST['boardname']))
{
	$_boardname = trim($_POST['boardname']);
	$_boardintroduction = trim($_POST['boardintroduction']);
	$_boardrules = trim($_POST['boardrules']);
	
	if(strlen($_boardname) < 5)
	{
		$error = "Board name is too short";
	} elseif(strlen($_boardname) > 100) {
		$error = "Board name is too long (100 characters maximum)";
	} else {
		config_set("BoardName", $_boardname);
		config_set("BoardIntroduction", $_boardintroduction);
		config_set("BoardRules", $_boardrules);
		$success = "Settings saved successfully";
	}
}

if(isset($success))
{
	page_section("Success");
	print $success;
	page_section();
}
if(isset($error))
{
	page_section("Error");
	print "<b style=\"color: #FF0000;\">$error</b>";
	page_section();
}

page_section();
print "<a href=\"page.admin.php\">Return to Administration tasks</a>";
page_section();

print "<form onsubmit=\"document.getElementById('go').disabled=true;document.getElementById('go').innerHTML='Patience!';\" action=\"?\" method=\"POST\">\n";
page_section();
print "<p>Board name:<br><input value=\"" . htmlentities($_boardname) . "\" name=\"boardname\" size=\"40\"><br><i>For example, EasyCB Sample Boards</i></p>\n";
print "<p>Board introduction:<br><textarea name=\"boardintroduction\" rows=\"10\" cols=\"40\">" . htmlentities($_boardintroduction) . "</textarea><br><i>This text is shown on the boards front page.</i></p>\n";
print "<p>Board rules:<br><textarea name=\"boardrules\" rows=\"10\" cols=\"40\">" . htmlentities($_boardrules) . "</textarea><br><i>This text is shown on the boards registration page.</i></p>\n";
print "<button id=\"go\" type=\"submit\">Save settings</button>\n";
page_section();
print "</form>\n";

page_footer('$Id: page.admin.config.php 107 2007-09-05 14:29:48Z jonathon.keogh $');

?>